const { query } = require('./config/database')

async function checkFields () {
  try {
    console.log('检查users表字段...')
    const users = await query('DESCRIBE users')
    console.log(
      'users表字段:',
      users.map(field => field.Field)
    )

    console.log('\n检查payment_orders表字段...')
    const orders = await query('DESCRIBE payment_orders')
    console.log(
      'payment_orders表字段:',
      orders.map(field => field.Field)
    )

    console.log('\n检查当前用户数据...')
    const userData = await query('SELECT * FROM users LIMIT 1')
    if (userData.length > 0) {
      console.log('用户数据示例:', Object.keys(userData[0]))
    }

    console.log('\n检查订单数据...')
    const orderData = await query('SELECT * FROM payment_orders LIMIT 1')
    if (orderData.length > 0) {
      console.log('订单数据示例:', Object.keys(orderData[0]))
    } else {
      console.log('暂无订单数据')
    }

    process.exit(0)
  } catch (error) {
    console.error('检查失败:', error.message)
    process.exit(1)
  }
}

checkFields()
